From: Yehuda Katz Date: Mon, 26 May 2014 18:52:33 +0000 (-0700) Subject: Up to date with master (StrBuf->String) X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~1051 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=2f5761755987628630cc8ea64dd51bdb06391b2f;p=cargo.git Up to date with master (StrBuf->String) --- diff --git a/libs/hammer.rs b/libs/hammer.rs index c305bcb84..5fbc58a5f 160000 --- a/libs/hammer.rs +++ b/libs/hammer.rs @@ -1 +1 @@ -Subproject commit c305bcb84ed51d7bd808bc20c09c00a1beb1b087 +Subproject commit 5fbc58a5f2251c427f405234a52a4bb54241b19a diff --git a/libs/rust-toml b/libs/rust-toml index 0de103ed1..ca130156b 160000 --- a/libs/rust-toml +++ b/libs/rust-toml @@ -1 +1 @@ -Subproject commit 0de103ed19997884f2766456f7a003b94f1daa42 +Subproject commit ca130156b599a8f48e0edee3e782e8de93e00c34 diff --git a/src/bin/cargo-compile.rs b/src/bin/cargo-compile.rs index a54d5f790..bbfb78ad7 100644 --- a/src/bin/cargo-compile.rs +++ b/src/bin/cargo-compile.rs @@ -18,7 +18,7 @@ use cargo::util::ToCLI; #[deriving(Eq,Clone,Decodable,Encodable)] pub struct Options { - manifest_path: Option + manifest_path: Option } impl FlagConfig for Options {} @@ -32,7 +32,7 @@ fn execute(options: Options) -> CLIResult> { let root = match options.manifest_path { Some(path) => Path::new(path), - None => try!(find_project(os::getcwd(), "Cargo.toml".to_owned()) + None => try!(find_project(os::getcwd(), "Cargo.toml") .map(|path| path.join("Cargo.toml")) .to_result(|err| CLIError::new("Could not find Cargo.toml in this directory or any parent directory", Some(err), 102))) diff --git a/src/bin/cargo-git-checkout.rs b/src/bin/cargo-git-checkout.rs index dbb17689f..911026493 100644 --- a/src/bin/cargo-git-checkout.rs +++ b/src/bin/cargo-git-checkout.rs @@ -7,16 +7,15 @@ extern crate url; use hammer::FlagConfig; use cargo::{execute_main_without_stdin,CLIResult,CLIError,ToResult}; -use cargo::core::Package; -use cargo::util::{Require,ToCLI,simple_human}; +use cargo::util::ToCLI; use cargo::sources::git::{GitCommand,GitRepo}; use url::Url; #[deriving(Eq,Clone,Decodable)] struct Options { - directory: StrBuf, - url: StrBuf, - reference: StrBuf + directory: String, + url: String, + reference: String } impl FlagConfig for Options {} diff --git a/src/bin/cargo-read-manifest.rs b/src/bin/cargo-read-manifest.rs index e8758e4e9..0d6846705 100644 --- a/src/bin/cargo-read-manifest.rs +++ b/src/bin/cargo-read-manifest.rs @@ -12,7 +12,7 @@ use cargo::ops; #[deriving(Eq,Clone,Decodable)] struct Options { - manifest_path: StrBuf + manifest_path: String } impl FlagConfig for Options {} @@ -23,9 +23,5 @@ fn main() { fn execute(options: Options) -> CLIResult> { ops::read_manifest(options.manifest_path.as_slice()).map(|m| Some(m)) - .map_err(|err| CLIError { - msg: err.get_desc().to_strbuf(), - detail: err.get_detail().map(|s| s.to_strbuf()), - exit_code: 1 - }) + .map_err(|err| CLIError::new(err.get_desc(), Some(err.get_detail()), 1)) } diff --git a/src/bin/cargo-verify-project.rs b/src/bin/cargo-verify-project.rs index c04287cff..92d23568a 100644 --- a/src/bin/cargo-verify-project.rs +++ b/src/bin/cargo-verify-project.rs @@ -12,7 +12,7 @@ use getopts::{reqopt,getopts}; */ fn main() { - let arguments: Vec = args().iter().map(|a| a.to_strbuf()).collect(); + let arguments = args(); let opts = vec!( reqopt("m", "manifest", "the location of the manifest", "MANIFEST") diff --git a/src/bin/cargo.rs b/src/bin/cargo.rs index db3558616..8b0c626ce 100644 --- a/src/bin/cargo.rs +++ b/src/bin/cargo.rs @@ -22,7 +22,7 @@ fn main() { #[deriving(Encodable)] struct ProjectLocation { - root: StrBuf + root: String } /** @@ -38,15 +38,15 @@ fn execute() { Err(err) => return handle_error(err) }; - if cmd == "config-for-key".to_strbuf() { + if cmd == "config-for-key".to_str() { log!(4, "cmd == config-for-key"); execute_main_without_stdin(config_for_key) } - else if cmd == "config-list".to_strbuf() { + else if cmd == "config-list".to_str() { log!(4, "cmd == config-list"); execute_main_without_stdin(config_list) } - else if cmd == "locate-project".to_strbuf() { + else if cmd == "locate-project".to_str() { log!(4, "cmd == locate-project"); execute_main_without_stdin(locate_project) } @@ -57,22 +57,22 @@ fn execute() { } } -fn process(args: Vec<~str>) -> CLIResult<(StrBuf, Vec)> { - let args: Vec = args.tail().iter().map(|a| a.to_strbuf()).collect(); +fn process(args: Vec) -> CLIResult<(String, Vec)> { + let args: Vec = Vec::from_slice(args.tail()); let head = try!(args.iter().nth(0).to_result(|_| CLIError::new("No subcommand found", None::<&str>, 1))).to_owned(); let tail = Vec::from_slice(args.tail()); - Ok((head.to_strbuf(), tail)) + Ok((head, tail)) } #[deriving(Encodable)] struct ConfigOut { - values: collections::HashMap + values: collections::HashMap } #[deriving(Decodable)] struct ConfigForKeyFlags { - key: StrBuf, + key: String, human: bool } @@ -128,5 +128,5 @@ fn locate_project(_: NoFlags) -> CLIResult> { let string = try!(root.as_str().to_result(|_| CLIError::new(format!("Your project path contains characters not representable in Unicode: {}", os::getcwd().display()), None::<&str>, 1))); - Ok(Some(ProjectLocation { root: string.to_strbuf() })) + Ok(Some(ProjectLocation { root: string.to_str() })) } diff --git a/src/cargo/core/dependency.rs b/src/cargo/core/dependency.rs index 2e0109e16..ce7b9c273 100644 --- a/src/cargo/core/dependency.rs +++ b/src/cargo/core/dependency.rs @@ -4,28 +4,28 @@ use util::CargoResult; #[deriving(Eq,Clone,Show)] pub struct Dependency { - name: StrBuf, + name: String, req: VersionReq } impl Dependency { pub fn new(name: &str, req: &VersionReq) -> Dependency { Dependency { - name: name.to_strbuf(), + name: name.to_str(), req: req.clone() } } pub fn parse(name: &str, version: &str) -> CargoResult { Ok(Dependency { - name: name.to_strbuf(), + name: name.to_str(), req: try!(VersionReq::parse(version)) }) } pub fn exact(name: &str, version: &Version) -> Dependency { Dependency { - name: name.to_strbuf(), + name: name.to_str(), req: VersionReq::exact(version) } } @@ -41,15 +41,15 @@ impl Dependency { #[deriving(Eq,Clone,Encodable)] pub struct SerializedDependency { - name: StrBuf, - req: StrBuf + name: String, + req: String } impl SerializedDependency { pub fn from_dependency(dep: &Dependency) -> SerializedDependency { SerializedDependency { - name: dep.get_name().to_strbuf(), - req: format_strbuf!("{}", dep.get_version_req()) + name: dep.get_name().to_str(), + req: dep.get_version_req().to_str() } } } diff --git a/src/cargo/core/errors.rs b/src/cargo/core/errors.rs index 8e3fc9184..bcd2ee141 100644 --- a/src/cargo/core/errors.rs +++ b/src/cargo/core/errors.rs @@ -24,15 +24,15 @@ impl Show for CargoError { } pub struct CLIError { - pub msg: StrBuf, - pub detail: Option, + pub msg: String, + pub detail: Option, pub exit_code: uint } impl CLIError { pub fn new(msg: T, detail: Option, exit_code: uint) -> CLIError { - let detail = detail.map(|d| format_strbuf!("{}", d)); - CLIError { msg: format_strbuf!("{}", msg), detail: detail, exit_code: exit_code } + let detail = detail.map(|d| d.to_str()); + CLIError { msg: msg.to_str(), detail: detail, exit_code: exit_code } } } @@ -43,11 +43,11 @@ impl Show for CLIError { } pub enum InternalError { - StringConversionError(StrBuf, &'static str), - MissingManifest(Path, StrBuf), + StringConversionError(String, &'static str), + MissingManifest(Path, String), WrappedIoError(IoError), - PathError(StrBuf), - Described(StrBuf), + PathError(String), + Described(String), Other } @@ -72,7 +72,7 @@ impl Show for InternalError { } impl CargoError { - pub fn cli(msg: StrBuf, detail: Option, exit_code: uint) -> CargoError { + pub fn cli(msg: String, detail: Option, exit_code: uint) -> CargoError { CargoCLIError(CLIError::new(msg, detail, exit_code)) } @@ -81,7 +81,7 @@ impl CargoError { } pub fn described(description: T) -> CargoError { - CargoInternalError(Described(format_strbuf!("{}", description))) + CargoInternalError(Described(description.to_str())) } pub fn other() -> CargoError { diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index d94c86c65..34f11fe0d 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -15,7 +15,7 @@ use util::CargoResult; #[deriving(Eq,Clone)] pub struct Manifest { summary: Summary, - authors: Vec, + authors: Vec, targets: Vec, target_dir: Path, } @@ -28,23 +28,23 @@ impl Show for Manifest { #[deriving(Eq,Clone,Encodable)] pub struct SerializedManifest { - name: StrBuf, - version: StrBuf, + name: String, + version: String, dependencies: Vec, - authors: Vec, + authors: Vec, targets: Vec, - target_dir: StrBuf + target_dir: String } impl> Encodable for Manifest { fn encode(&self, s: &mut S) -> Result<(), E> { SerializedManifest { - name: self.summary.get_name().to_strbuf(), - version: format_strbuf!("{}", self.summary.get_version()), + name: self.summary.get_name().to_str(), + version: self.summary.get_version().to_str(), dependencies: self.summary.get_dependencies().iter().map(|d| SerializedDependency::from_dependency(d)).collect(), authors: self.authors.clone(), targets: self.targets.clone(), - target_dir: self.target_dir.as_str().unwrap().to_strbuf() + target_dir: self.target_dir.display().to_str() }.encode(s) } } @@ -58,15 +58,15 @@ pub enum TargetKind { #[deriving(Clone,Eq)] pub struct Target { kind: TargetKind, - name: StrBuf, + name: String, path: Path } #[deriving(Encodable)] pub struct SerializedTarget { kind: &'static str, - name: StrBuf, - path: StrBuf + name: String, + path: String } impl> Encodable for Target { @@ -79,7 +79,7 @@ impl> Encodable for Target { SerializedTarget { kind: kind, name: self.name.clone(), - path: self.path.as_str().unwrap().to_strbuf() + path: self.path.display().to_str() }.encode(s) } } @@ -112,7 +112,7 @@ impl Manifest { self.get_summary().get_name_ver().get_version() } - pub fn get_authors<'a>(&'a self) -> &'a [StrBuf] { + pub fn get_authors<'a>(&'a self) -> &'a [String] { self.authors.as_slice() } @@ -133,7 +133,7 @@ impl Target { pub fn lib_target(name: &str, path: &Path) -> Target { Target { kind: LibTarget, - name: name.to_strbuf(), + name: name.to_str(), path: path.clone() } } @@ -141,7 +141,7 @@ impl Target { pub fn bin_target(name: &str, path: &Path) -> Target { Target { kind: BinTarget, - name: name.to_strbuf(), + name: name.to_str(), path: path.clone() } } @@ -169,9 +169,9 @@ type TomlExecTarget = TomlTarget; #[deriving(Decodable,Encodable,Eq,Clone,Show)] pub struct Project { - pub name: StrBuf, - pub version: StrBuf, - pub authors: Vec + pub name: String, + pub version: String, + pub authors: Vec } /* @@ -183,7 +183,7 @@ pub struct TomlManifest { project: Box, lib: Option<~[TomlLibTarget]>, bin: Option<~[TomlExecTarget]>, - dependencies: Option> + dependencies: Option> } impl TomlManifest { @@ -226,18 +226,18 @@ impl Project { #[deriving(Decodable,Encodable,Eq,Clone)] struct TomlTarget { - name: StrBuf, - path: Option + name: String, + path: Option } fn normalize(lib: &Option<~[TomlLibTarget]>, bin: &Option<~[TomlExecTarget]>) -> Vec { fn lib_targets(dst: &mut Vec, libs: &[TomlLibTarget]) { let l = &libs[0]; - let path = l.path.clone().unwrap_or_else(|| format_strbuf!("src/{}.rs", l.name)); + let path = l.path.clone().unwrap_or_else(|| format!("src/{}.rs", l.name)); dst.push(Target::lib_target(l.name.as_slice(), &Path::new(path))); } - fn bin_targets(dst: &mut Vec, bins: &[TomlExecTarget], default: |&TomlExecTarget| -> StrBuf) { + fn bin_targets(dst: &mut Vec, bins: &[TomlExecTarget], default: |&TomlExecTarget| -> String) { for bin in bins.iter() { let path = bin.path.clone().unwrap_or_else(|| default(bin)); dst.push(Target::bin_target(bin.name.as_slice(), &Path::new(path))); @@ -249,13 +249,13 @@ fn normalize(lib: &Option<~[TomlLibTarget]>, bin: &Option<~[TomlExecTarget]>) -> match (lib, bin) { (&Some(ref libs), &Some(ref bins)) => { lib_targets(&mut ret, libs.as_slice()); - bin_targets(&mut ret, bins.as_slice(), |bin| format_strbuf!("src/bin/{}.rs", bin.name)); + bin_targets(&mut ret, bins.as_slice(), |bin| format!("src/bin/{}.rs", bin.name)); }, (&Some(ref libs), &None) => { lib_targets(&mut ret, libs.as_slice()); }, (&None, &Some(ref bins)) => { - bin_targets(&mut ret, bins.as_slice(), |bin| format_strbuf!("src/{}.rs", bin.name)); + bin_targets(&mut ret, bins.as_slice(), |bin| format!("src/{}.rs", bin.name)); }, (&None, &None) => () } diff --git a/src/cargo/core/namever.rs b/src/cargo/core/namever.rs index 18b975719..7dfc85252 100644 --- a/src/cargo/core/namever.rs +++ b/src/cargo/core/namever.rs @@ -10,13 +10,13 @@ use serialize::{ #[deriving(Clone,Eq,Ord)] pub struct NameVer { - name: StrBuf, + name: String, version: semver::Version } impl NameVer { pub fn new(name: &str, version: &str) -> NameVer { - NameVer { name: name.to_strbuf(), version: semver::parse(version.to_owned()).unwrap() } + NameVer { name: name.to_str(), version: semver::parse(version.as_slice()).unwrap() } } pub fn get_name<'a>(&'a self) -> &'a str { @@ -36,13 +36,13 @@ impl Show for NameVer { impl> Decodable for NameVer { fn decode(d: &mut D) -> Result { - let vector: Vec = try!(Decodable::decode(d)); + let vector: Vec = try!(Decodable::decode(d)); Ok(NameVer { name: vector.get(0).clone(), version: semver::parse(vector.get(1).as_slice()).unwrap() }) } } impl> Encodable for NameVer { fn encode(&self, e: &mut S) -> Result<(), E> { - (vec!(self.name.clone(), format_strbuf!("{}", self.version))).encode(e) + (vec!(self.name.clone(), self.version.to_str())).encode(e) } } diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index b054f8b7c..bc8064ef8 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -23,12 +23,12 @@ pub struct Package { #[deriving(Encodable)] struct SerializedPackage { - name: StrBuf, - version: StrBuf, + name: String, + version: String, dependencies: Vec, - authors: Vec, + authors: Vec, targets: Vec, - root: StrBuf + root: String } impl> Encodable for Package { @@ -38,12 +38,12 @@ impl> Encodable for Package { let name_ver = summary.get_name_ver(); SerializedPackage { - name: name_ver.get_name().to_strbuf(), - version: format_strbuf!("{}", name_ver.get_version()), + name: name_ver.get_name().to_str(), + version: name_ver.get_version().to_str(), dependencies: summary.get_dependencies().iter().map(|d| SerializedDependency::from_dependency(d)).collect(), authors: Vec::from_slice(manifest.get_authors()), targets: Vec::from_slice(manifest.get_targets()), - root: self.root.as_str().unwrap().to_strbuf() + root: self.root.display().to_str() }.encode(s) } } diff --git a/src/cargo/core/summary.rs b/src/cargo/core/summary.rs index de86b39e9..49d87fdd1 100644 --- a/src/cargo/core/summary.rs +++ b/src/cargo/core/summary.rs @@ -36,14 +36,14 @@ impl Summary { } pub trait SummaryVec { - fn names(&self) -> Vec; + fn names(&self) -> Vec; fn deps(&self) -> Vec; } impl SummaryVec for Vec { - // TODO: Move to Registery - fn names(&self) -> Vec { - self.iter().map(|summary| summary.name_ver.get_name().to_strbuf()).collect() + // TODO: Move to Registry + fn names(&self) -> Vec { + self.iter().map(|summary| summary.name_ver.get_name().to_str()).collect() } // TODO: Delete diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index c497df809..9e6e3d33f 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -89,8 +89,8 @@ pub fn handle_error(err: CLIError) { std::os::set_exit_status(exit_code as int); } -fn args() -> Vec { - std::os::args().iter().map(|a| a.to_strbuf()).collect() +fn args() -> Vec { + std::os::args() } fn flags_from_args() -> CLIResult { @@ -102,7 +102,7 @@ fn json_from_stdin() -> CLIResult { let mut reader = io::stdin(); let input = try!(reader.read_to_str().to_result(|_| CLIError::new("Standard in did not exist or was not UTF-8", None::<&str>, 1))); - let json = try!(json::from_str(input).to_result(|_| CLIError::new("Could not parse standard in as JSON", Some(input.to_strbuf()), 1))); + let json = try!(json::from_str(input.as_slice()).to_result(|_| CLIError::new("Could not parse standard in as JSON", Some(input.clone()), 1))); let mut decoder = json::Decoder::new(json); Decodable::decode(&mut decoder).to_result(|e: json::DecoderError| CLIError::new("Could not process standard in as input", Some(e), 1)) diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index f1a98248e..a01004d0c 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -30,7 +30,7 @@ pub fn compile(manifest_path: &str) -> CargoResult<()> { let configs = try!(config::all_configs(os::getcwd())); - let config_paths = configs.find(&"paths".to_strbuf()).map(|v| v.clone()).unwrap_or_else(|| ConfigValue::new()); + let config_paths = configs.find_equiv(&"paths").map(|v| v.clone()).unwrap_or_else(|| ConfigValue::new()); let mut paths: Vec = match config_paths.get_value() { &config::String(_) => return Err(other_error("The path was configured as a String instead of a List")), diff --git a/src/cargo/ops/cargo_read_manifest.rs b/src/cargo/ops/cargo_read_manifest.rs index cf44be3a1..53f175fcd 100644 --- a/src/cargo/ops/cargo_read_manifest.rs +++ b/src/cargo/ops/cargo_read_manifest.rs @@ -6,10 +6,10 @@ use util::{toml_error,human_error,CargoResult,CargoError}; pub fn read_manifest(path: &str) -> CargoResult { let root = try!(parse_from_file(path).map_err(|err: CargoError| - human_error("Cargo.toml is not valid Toml".to_strbuf(), format_strbuf!("path={}", path), err))); + human_error("Cargo.toml is not valid Toml".to_str(), format!("path={}", path), err))); let toml = try!(load_toml(root).map_err(|err: CargoError| - human_error("Cargo.toml is not a valid Cargo manifest".to_strbuf(), format_strbuf!("path={}", path), err))); + human_error("Cargo.toml is not a valid Cargo manifest".to_str(), format!("path={}", path), err))); toml.to_package(path) } diff --git a/src/cargo/ops/cargo_rustc.rs b/src/cargo/ops/cargo_rustc.rs index 9a18b65fd..2629cb2c5 100644 --- a/src/cargo/ops/cargo_rustc.rs +++ b/src/cargo/ops/cargo_rustc.rs @@ -7,7 +7,7 @@ use util; use util::{other_error,human_error,CargoResult,CargoError,ProcessBuilder}; use util::result::ProcessError; -type Args = Vec; +type Args = Vec; pub fn compile_packages(pkgs: &core::PackageSet) -> CargoResult<()> { let mut sorted = match pkgs.sort() { @@ -69,33 +69,39 @@ fn prepare_rustc(root: &Path, target: &core::Target, dest: &Path, deps: &[core:: } fn build_base_args(into: &mut Args, target: &core::Target, dest: &Path) { - into.push(target.get_path().as_str().unwrap().to_strbuf()); - into.push("--crate-type".to_strbuf()); - into.push(target.rustc_crate_type().to_strbuf()); - into.push("--out-dir".to_strbuf()); - into.push(dest.as_str().unwrap().to_strbuf()); + // TODO: Handle errors in converting paths into args + into.push(target.get_path().display().to_str()); + into.push("--crate-type".to_str()); + into.push(target.rustc_crate_type().to_str()); + into.push("--out-dir".to_str()); + into.push(dest.display().to_str()); } fn build_deps_args(dst: &mut Args, deps: &[core::Package]) { for dep in deps.iter() { let dir = dep.get_absolute_target_dir(); - dst.push("-L".to_strbuf()); - dst.push(dir.as_str().unwrap().to_strbuf()); + dst.push("-L".to_str()); + dst.push(dir.display().to_str()); } } -fn rustc_to_cargo_err(args: &[StrBuf], cwd: &Path, err: CargoError) -> CargoError { +fn rustc_to_cargo_err(args: &[String], cwd: &Path, err: CargoError) -> CargoError { let msg = { let output = match err { CargoError { kind: ProcessError(_, ref output), .. } => output, _ => fail!("Bug! exec() returned an error other than a ProcessError") }; - let mut msg = StrBuf::from_str(format!("failed to execute: `rustc {}`", args.connect(" "))); - output.as_ref().map(|o| msg.push_str(format!("; Error:\n{}", str::from_utf8_lossy(o.error.as_slice())))); + let mut msg = format!("failed to execute: `rustc {}`", args.connect(" ")); + + output.as_ref().map(|o| { + let second = format!("; Error:\n{}", str::from_utf8_lossy(o.error.as_slice())); + msg.push_str(second.as_slice()); + }); + msg }; - human_error(msg, format_strbuf!("root={}", cwd.display()), err) + human_error(msg, format!("root={}", cwd.display()), err) } diff --git a/src/cargo/sources/git.rs b/src/cargo/sources/git.rs index cc7a6ba9d..03af0356a 100644 --- a/src/cargo/sources/git.rs +++ b/src/cargo/sources/git.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + use url::Url; use util::{CargoResult,ProcessBuilder,io_error,human_error,process}; use std::str; @@ -7,21 +9,21 @@ use serialize::{Encodable,Encoder}; macro_rules! git( ($config:expr, $str:expr, $($rest:expr),*) => ( - try!(git_inherit(&$config, format_strbuf!($str, $($rest),*))) + try!(git_inherit(&$config, format!($str, $($rest),*))) ); ($config:expr, $str:expr) => ( - try!(git_inherit(&$config, format_strbuf!($str))) + try!(git_inherit(&$config, format!($str))) ); ) macro_rules! git_output( ($config:expr, $str:expr, $($rest:expr),*) => ( - try!(git_output(&$config, format_strbuf!($str, $($rest),*))) + try!(git_output(&$config, format!($str, $($rest),*))) ); ($config:expr, $str:expr) => ( - try!(git_output(&$config, format_strbuf!($str))) + try!(git_output(&$config, format!($str))) ); ) @@ -29,21 +31,21 @@ macro_rules! git_output( struct GitConfig { path: Path, uri: Url, - reference: StrBuf + reference: String } #[deriving(Eq,Clone,Encodable)] struct EncodableGitConfig { - path: StrBuf, - uri: StrBuf, - reference: StrBuf + path: String, + uri: String, + reference: String } impl> Encodable for GitConfig { fn encode(&self, s: &mut S) -> Result<(), E> { EncodableGitConfig { - path: format_strbuf!("{}", self.path.display()), - uri: format_strbuf!("{}", self.uri), + path: self.path.display().to_str(), + uri: self.uri.to_str(), reference: self.reference.clone() }.encode(s) } @@ -57,11 +59,11 @@ pub struct GitCommand { #[deriving(Eq,Clone,Encodable)] pub struct GitRepo { config: GitConfig, - revision: StrBuf + revision: String } impl GitCommand { - pub fn new(path: Path, uri: Url, reference: StrBuf) -> GitCommand { + pub fn new(path: Path, uri: Url, reference: String) -> GitCommand { GitCommand { config: GitConfig { path: path, uri: uri, reference: reference } } } @@ -76,7 +78,7 @@ impl GitCommand { checkout_config.path = dirname; try!(mkdir_recursive(&checkout_config.path, UserDir).map_err(|err| - human_error(format_strbuf!("Couldn't recursively create `{}`", checkout_config.path.display()), format_strbuf!("path={}", checkout_config.path.display()), io_error(err)))); + human_error(format!("Couldn't recursively create `{}`", checkout_config.path.display()), format!("path={}", checkout_config.path.display()), io_error(err)))); git!(checkout_config, "clone {} {} --bare --no-hardlinks --quiet", config.uri, config.path.display()); } @@ -86,6 +88,7 @@ impl GitCommand { } impl GitRepo { + #[allow(unused_variable)] fn copy_to(destination: &Path) -> CargoResult<()> { Ok(()) } @@ -107,7 +110,7 @@ impl GitRepo { } } -fn rev_for(config: &GitConfig) -> CargoResult { +fn rev_for(config: &GitConfig) -> CargoResult { Ok(git_output!(*config, "rev-parse {}", config.reference)) } @@ -116,18 +119,18 @@ fn git(config: &GitConfig, str: &str) -> ProcessBuilder { process("git").args(str.split(' ').collect::>().as_slice()).cwd(config.path.clone()) } -fn git_inherit(config: &GitConfig, str: StrBuf) -> CargoResult<()> { +fn git_inherit(config: &GitConfig, str: String) -> CargoResult<()> { git(config, str.as_slice()).exec().map_err(|err| - human_error(format_strbuf!("Couldn't execute `git {}`: {}", str, err), None::<&str>, err)) + human_error(format!("Couldn't execute `git {}`: {}", str, err), None::<&str>, err)) } -fn git_output(config: &GitConfig, str: StrBuf) -> CargoResult { +fn git_output(config: &GitConfig, str: String) -> CargoResult { let output = try!(git(config, str.as_slice()).exec_with_output().map_err(|err| - human_error(format_strbuf!("Couldn't execute `git {}`", str), None::<&str>, err))); + human_error(format!("Couldn't execute `git {}`", str), None::<&str>, err))); Ok(to_str(output.output.as_slice())) } -fn to_str(vec: &[u8]) -> StrBuf { - format_strbuf!("{}", str::from_utf8_lossy(vec)) +fn to_str(vec: &[u8]) -> String { + str::from_utf8_lossy(vec).to_str() } diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index 83bf2f342..308d44f89 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -12,8 +12,8 @@ pub enum Location { #[deriving(Eq,TotalEq,Clone,Decodable)] pub enum ConfigValueValue { - String(StrBuf), - List(Vec) + String(String), + List(Vec) } impl fmt::Show for ConfigValueValue { @@ -68,7 +68,7 @@ impl> Encodable for ConfigValue { impl fmt::Show for ConfigValue { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let paths: Vec = self.path.iter().map(|p| format_strbuf!("{}", p.display())).collect(); + let paths: Vec = self.path.iter().map(|p| p.display().to_str()).collect(); write!(f, "{} (from {})", self.value, paths) } } @@ -78,7 +78,7 @@ pub fn get_config(pwd: Path, key: &str) -> CargoResult { .map_err(|_| other_error("config key not found").with_detail(format!("key={}", key))) } -pub fn all_configs(pwd: Path) -> CargoResult> { +pub fn all_configs(pwd: Path) -> CargoResult> { let mut map = HashMap::new(); try!(walk_tree(&pwd, |file| { @@ -89,7 +89,7 @@ pub fn all_configs(pwd: Path) -> CargoResult> { } #[allow(unused_variable)] -pub fn set_config(key: StrBuf, value: StrBuf, location: Location) -> CargoResult<()> { +pub fn set_config(key: String, value: String, location: Location) -> CargoResult<()> { Ok(()) } @@ -141,14 +141,14 @@ fn extract_config(file: io::fs::File, key: &str) -> CargoResult { let v = match val { &toml::String(ref val) => String(val.clone()), - &toml::Array(ref val) => List(val.iter().map(|s: &toml::Value| format_strbuf!("{}", s)).collect()), + &toml::Array(ref val) => List(val.iter().map(|s: &toml::Value| s.to_str()).collect()), _ => return Err(other_error("")) }; Ok(ConfigValue{ value: v, path: vec!(path) }) } -fn extract_all_configs(file: io::fs::File, map: &mut HashMap) -> CargoResult<()> { +fn extract_all_configs(file: io::fs::File, map: &mut HashMap) -> CargoResult<()> { let path = file.path().clone(); let mut buf = io::BufferedReader::new(file); let root = try!(toml::parse_from_buffer(&mut buf).map_err(|err| @@ -179,11 +179,11 @@ fn merge_array(existing: &mut ConfigValue, val: &[toml::Value], path: &Path) -> match existing.value { String(_) => return Err(other_error("should be an Array, but it was a String")), List(ref mut list) => { - let new_list: Vec> = val.iter().map(|s: &toml::Value| toml_string(s)).collect(); + let new_list: Vec> = val.iter().map(|s: &toml::Value| toml_string(s)).collect(); if new_list.iter().any(|v| v.is_err()) { return Err(other_error("should be an Array of Strings, but was an Array of other values")); } else { - let new_list: Vec = new_list.move_iter().map(|v| v.unwrap()).collect(); + let new_list: Vec = new_list.move_iter().map(|v| v.unwrap()).collect(); list.push_all(new_list.as_slice()); existing.path.push(path.clone()); Ok(()) @@ -192,7 +192,7 @@ fn merge_array(existing: &mut ConfigValue, val: &[toml::Value], path: &Path) -> } } -fn toml_string(val: &toml::Value) -> CargoResult { +fn toml_string(val: &toml::Value) -> CargoResult { match val { &toml::String(ref str) => Ok(str.clone()), _ => Err(other_error("")) diff --git a/src/cargo/util/process_builder.rs b/src/cargo/util/process_builder.rs index 37b4da7a2..972d40949 100644 --- a/src/cargo/util/process_builder.rs +++ b/src/cargo/util/process_builder.rs @@ -8,10 +8,10 @@ use collections::HashMap; #[deriving(Clone,Eq)] pub struct ProcessBuilder { - program: StrBuf, - args: Vec, - path: Vec, - env: HashMap, + program: String, + args: Vec, + path: Vec, + env: HashMap, cwd: Path } @@ -32,17 +32,17 @@ static PATH_SEP : &'static str = ":"; impl ProcessBuilder { pub fn args(mut self, arguments: &[T]) -> ProcessBuilder { - self.args = arguments.iter().map(|a| format_strbuf!("{}", a)).collect(); + self.args = arguments.iter().map(|a| a.to_str()).collect(); self } - pub fn get_args<'a>(&'a self) -> &'a [StrBuf] { + pub fn get_args<'a>(&'a self) -> &'a [String] { self.args.as_slice() } pub fn extra_path(mut self, path: Path) -> ProcessBuilder { // For now, just convert to a string, but we should do something better - self.path.push(format_strbuf!("{}", path.display())); + self.path.push(path.display().to_str()); self } @@ -64,7 +64,7 @@ impl ProcessBuilder { if exit.success() { Ok(()) } else { - let msg = format_strbuf!("Could not execute process `{}`", self.debug_string()); + let msg = format!("Could not execute process `{}`", self.debug_string()); Err(process_error(msg, exit, None)) } } @@ -78,7 +78,7 @@ impl ProcessBuilder { if output.status.success() { Ok(output) } else { - let msg = format_strbuf!("Could not execute process `{}`", self.debug_string()); + let msg = format!("Could not execute process `{}`", self.debug_string()); Err(process_error(msg, output.status.clone(), Some(output))) } } @@ -89,11 +89,11 @@ impl ProcessBuilder { command } - fn debug_string(&self) -> StrBuf { - format_strbuf!("{} {}", self.program, self.args.connect(" ")) + fn debug_string(&self) -> String { + format!("{} {}", self.program, self.args.connect(" ")) } - fn build_env(&self) -> ~[(StrBuf, StrBuf)] { + fn build_env(&self) -> ~[(String, String)] { let mut ret = Vec::new(); for (key, val) in self.env.iter() { @@ -104,14 +104,14 @@ impl ProcessBuilder { } match self.build_path() { - Some(path) => ret.push(("PATH".to_strbuf(), path)), + Some(path) => ret.push(("PATH".to_str(), path)), _ => () } ret.as_slice().to_owned() } - fn build_path(&self) -> Option { + fn build_path(&self) -> Option { let path = self.path.connect(PATH_SEP); match self.env.find_equiv(&("PATH")) { @@ -119,14 +119,14 @@ impl ProcessBuilder { if self.path.is_empty() { Some(existing.clone()) } else { - Some(format_strbuf!("{}{}{}", existing, PATH_SEP, path)) + Some(format!("{}{}{}", existing, PATH_SEP, path)) } }, None => { if self.path.is_empty() { None } else { - Some(path.to_strbuf()) + Some(path) } } } @@ -135,7 +135,7 @@ impl ProcessBuilder { pub fn process(cmd: &str) -> ProcessBuilder { ProcessBuilder { - program: cmd.to_strbuf(), + program: cmd.to_str(), args: vec!(), path: vec!(), cwd: os::getcwd(), @@ -143,11 +143,11 @@ pub fn process(cmd: &str) -> ProcessBuilder { } } -fn system_env() -> HashMap { +fn system_env() -> HashMap { let mut ret = HashMap::new(); for &(ref key, ref val) in os::env().iter() { - ret.insert(key.to_strbuf(), val.to_strbuf()); + ret.insert(key.to_str(), val.to_str()); } ret diff --git a/src/cargo/util/result.rs b/src/cargo/util/result.rs index f263b7ff1..8ce1b72fe 100644 --- a/src/cargo/util/result.rs +++ b/src/cargo/util/result.rs @@ -33,7 +33,7 @@ pub fn io_error(err: IoError) -> CargoError { } } -pub fn process_error(detail: StrBuf, exit: ProcessExit, output: Option) -> CargoError { +pub fn process_error(detail: String, exit: ProcessExit, output: Option) -> CargoError { CargoError { kind: ProcessError(exit, output), desc: BoxedDescription(detail), @@ -45,8 +45,8 @@ pub fn process_error(detail: StrBuf, exit: ProcessExit, output: Option(desc: T, detail: U, cause: CargoError) -> CargoError { CargoError { kind: HumanReadableError, - desc: BoxedDescription(desc.to_str().to_strbuf()), - detail: Some(detail.to_str().to_strbuf()), + desc: BoxedDescription(desc.to_str()), + detail: Some(detail.to_str()), cause: Some(box cause) } } @@ -54,7 +54,7 @@ pub fn human_error(desc: T, detail: U, cause: CargoError) -> pub fn simple_human(desc: T) -> CargoError { CargoError { kind: HumanReadableError, - desc: BoxedDescription(format_strbuf!("{}", desc)), + desc: BoxedDescription(desc.to_str()), detail: None, cause: None } @@ -73,14 +73,14 @@ pub fn toml_error(desc: &'static str, error: toml::Error) -> CargoError { pub struct CargoError { pub kind: CargoErrorKind, desc: CargoErrorDescription, - detail: Option, + detail: Option, cause: Option> } #[deriving(Show,Clone)] enum CargoErrorDescription { StaticDescription(&'static str), - BoxedDescription(StrBuf) + BoxedDescription(String) } impl CargoError { @@ -96,20 +96,20 @@ impl CargoError { } pub fn with_detail(mut self, detail: T) -> CargoError { - self.detail = Some(format_strbuf!("{}", detail)); + self.detail = Some(detail.to_str()); self } pub fn to_cli(self, exit_code: uint) -> CLIError { match self { CargoError { kind: HumanReadableError, desc: BoxedDescription(desc), detail: detail, .. } => { - CLIError::new(desc, detail.map(|d| d.to_strbuf()), exit_code) + CLIError::new(desc, detail, exit_code) }, CargoError { kind: InternalError, desc: StaticDescription(desc), detail: None, .. } => { CLIError::new("An unexpected error occurred", Some(desc), exit_code) }, CargoError { kind: InternalError, desc: StaticDescription(desc), detail: Some(detail), .. } => { - CLIError::new("An unexpected error occurred", Some(format_strbuf!("{}\n{}", desc, detail)), exit_code) + CLIError::new("An unexpected error occurred", Some(format!("{}\n{}", desc, detail)), exit_code) }, _ => { CLIError::new("An unexpected error occurred", None::<&str>, exit_code) @@ -164,7 +164,7 @@ pub struct CargoCliError { kind: CargoCliErrorKind, exit_status: uint, desc: &'static str, - detail: Option, + detail: Option, cause: Option }